<?php
	mysql_connect("localhost", "sapmenet_admin", "a1s2d3f4g5h6j7") or die ("Problem with datebase");
	mysql_select_db("sapmenet_users");
	echo"<link rel = 'stylesheet' type = 'text/css' href = 'searchStyle.css'>";
	$name=$_POST['name'];
	$name=htmlspecialchars($name);
	$name=mysql_real_escape_string($name);
	$name=explode(" ", $name);
	if (!isset($name[2]))
	{
		if (!isset($name[1]))
		{
			$result=mysql_query("SELECT concat(FirstName,' ',LastName) AS FullName, mainPic, ID FROM users WHERE FirstName LIKE '".$name[0]."'");
		}
		else
		{
			$result=mysql_query("SELECT concat(FirstName,' ',LastName) AS FullName, mainPic, ID FROM users WHERE FirstName LIKE '".$name[0]."' AND LastName LIKE '".$name[1]."'");
		}
		echo"<div id = 'bigDivFullOfResults'>";
		while($theResult = mysql_fetch_array($result, MYSQL_NUM))
			{
				$pic=$theResult[1]."mini.jpg";
				echo ("<a href=http://sapme.net/Framework/profilePage.php?id=".$theResult[2].">"."<div class = 'smallDivOfSingleResult'><img src=".$pic.">".$theResult[0]."</div></a>");
			}
			echo"</div>";
	}
	else
	{
		echo "Horata v toq sait imat samo po 2 imena be curvyl!!!!";
	}
	
?>